package ifosup.marie.calculatrice;

import javax.swing.JLabel;

public class Operation 
{
	public Operation()
	{}
	
	public static void afficherChiffre(int n, JLabel label)
	{
		if ((label.getText().equals("0")) || (label.getText().equals(" ")))
		{
			label.setText(String.valueOf(n));
		}
		else if ((label.getText().equals("-0")) || (label.getText().equals("-")))
		{
			label.setText("-" + n);
		}
		else label.setText(label.getText() + n);
	}
	
	public static void afficherPoint(JLabel label)
	{
		if (label.getText().equals(" "))
		{
			label.setText("0.");
		}
		else if (label.getText().equals("-"))
		{
			label.setText("-0.");
		}
		else if (label.getText().contains("."))
		{}
		else
		{
			label.setText(label.getText() + ".");	
		}
	}
	
	public static void afficherResultat(int operateur, double operande1, double operande2, JLabel label)
	{
		if (operateur == 1)
		{
			label.setText(String.valueOf(operande1 + operande2));
		}
		else if (operateur == 2)
		{
			label.setText(String.valueOf(operande1 - operande2));
		}
		else if (operateur == 3)
		{
			label.setText(String.valueOf(operande1 * operande2));
		}
		else if (operateur == 4)
		{
			label.setText(String.valueOf(operande1 / operande2));
		}
		else
		{}
		
	}

}
